<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>商品列表</h1>
<table border="1">
    <tr>
        <th>id</th>
        <th>标题</th>
        <th>价格</th>
        <th>销量</th>
        <th>操作</th>
    </tr>
    <tr v-for="product in arr">
        <td>{{product.id}}</td>
        <td>{{product.title}}</td>
        <td>{{product.price}}</td>
        <td>{{product.saleCount}}</td>
        <td>
            <a href="javascript:void (0)" @click="del(product.id)">删除</a>
            <a :href="'/update.html?id='+product.id">修改</a>
        </td>
    </tr>
</table>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"table",
        data:{
           arr:[]
        },
        created:function (){
            axios.get("/select").then(function (response){
                v.arr = response.data;
            })
        },
        methods:{
            del(id){
                axios.get("/delete?id="+id).then(function (response){
                    alert("删除成功!!!");
                    location.reload();
                })
            }
        }
    })
</script>
</body>
</html>